Skip to content

feat(traces): migrate trace propagation to dd-trace-rs#1089

Open
duncanista wants to merge 7 commits intomainfrom
jordan.gonzalez/propagation/migrate-to-dd-trace-rs
Open

feat(traces): migrate trace propagation to dd-trace-rs#1089
duncanista wants to merge 7 commits intomainfrom
jordan.gonzalez/propagation/migrate-to-dd-trace-rs

Conversation

@duncanista
Copy link
Contributor

@duncanista duncanista commented Mar 6, 2026

Overview

Migrate trace context propagation from a local implementation to the datadog-opentelemetry crate in dd-trace-rs. This removes ~750 lines of propagation logic (Datadog headers, W3C TraceContext) that we were maintaining locally in favor of the shared upstream
implementation.

Key changes:

  • Add datadog-opentelemetry as a dependency
  • Delete local propagation modules: traces/context.rs, traces/propagation/error.rs, traces/propagation/text_map_propagator.rs
  • Keep a thin DatadogCompositePropagator wrapper that adds ot-baggage-* header extraction, which is not yet supported upstream
  • Update all consumers to import SpanContext, Sampling, TracePropagationStyle, and header constants directly from datadog-opentelemetry
  • Adapt to upstream types: u128 trace IDs (cast to u64 for Datadog protocol), Sampling struct, SamplingPriority newtype

Motivation

Not have to own this piece as its tracer logic and SVLS-7466

Testing

  • All 476 existing tests pass
  • Propagation tests updated to use Datadog/TraceContext styles (upstream does not expose B3/B3Multi variants)
  • Config parsing tests updated to reflect valid upstream style names
  • Trace Propagation e2e tests pass

Replace local trace extraction/propagation implementation with
datadog-opentelemetry crate from dd-trace-rs. This removes maintenance
burden for Datadog/TraceContext propagator logic.

- Add datadog-opentelemetry dependency
- Remove local propagation modules (context, error, text_map_propagator)
- Use DatadogCompositePropagator from dd-trace-rs with thin wrapper
  for ot-baggage-* header extraction (not yet supported upstream)
- Update all consumers to import directly from datadog-opentelemetry
- Adapt to u128 trace_id, Sampling struct, SamplingPriority types
@duncanista duncanista requested a review from a team as a code owner March 6, 2026 22:41
@duncanista
Copy link
Contributor Author

Merge needs to be held until dd-trace-rs changes are on main or released

…ace IDs

The truncation is intentional — Datadog protocol transmits the lower
64 bits via x-datadog-trace-id, with upper bits in _dd.p.tid tag.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates trace context propagation from Bottlecap’s local implementation to datadog-opentelemetry (from dd-trace-rs), removing local Datadog/W3C propagation code while keeping a small wrapper to support ot-baggage-* extraction.

Changes:

  • Add datadog-opentelemetry dependency and adapt config to satisfy its propagation configuration trait.
  • Remove local propagation/context modules and update call sites to use upstream SpanContext, Sampling, TracePropagationStyle, and header constants.
  • Keep a thin DatadogCompositePropagator wrapper to add ot-baggage-* extraction not supported upstream yet.

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
bottlecap/src/traces/propagation/text_map_propagator.rs Deleted local header/W3C TraceContext propagators and tests.
bottlecap/src/traces/propagation/error.rs Deleted local propagation error type.
bottlecap/src/traces/context.rs Deleted local SpanContext/Sampling types in favor of upstream.
bottlecap/src/traces/mod.rs Removes context module export now that it’s deleted.
bottlecap/src/traces/propagation/mod.rs Replaces local multi-propagator logic with wrapper around upstream composite + baggage extraction.
bottlecap/src/traces/propagation/carrier.rs Switches carrier traits to upstream and introduces JsonCarrier newtypes for serde_json::Value.
bottlecap/src/otlp/transform.rs Imports Datadog trace-id-high constant from upstream.
bottlecap/src/lifecycle/listener.rs Updates injected headers to use upstream context/constants and u128 trace IDs.
bottlecap/src/lifecycle/invocation/processor.rs Updates extraction to use upstream propagator and JSON carriers; adjusts for u128 trace IDs.
bottlecap/src/lifecycle/invocation/processor_service.rs Updates SpanContext import to upstream.
bottlecap/src/lifecycle/invocation/span_inferrer.rs Replaces local propagator trait usage with DatadogCompositePropagator.
bottlecap/src/lifecycle/invocation/context.rs Switches to upstream SpanContext.
bottlecap/src/lifecycle/invocation/triggers/step_function_event.rs Updates to upstream SpanContext/Sampling and adds local _dd.p.* parsing helper.
bottlecap/src/lifecycle/invocation/triggers/sqs_event.rs Updates to upstream SpanContext/Sampling and u128 trace IDs.
bottlecap/src/config/trace_propagation_style.rs Uses upstream TracePropagationStyle and keeps only deserialization logic.
bottlecap/src/config/mod.rs Implements upstream PropagationConfig for Config; updates tests to match supported styles.
bottlecap/src/config/env.rs Adjusts env parsing tests/defaults to supported upstream style names.
bottlecap/src/config/yaml.rs Adjusts YAML sample/tests to supported upstream style names.
bottlecap/Cargo.toml Adds git dependency on datadog-opentelemetry.
bottlecap/Cargo.lock Updates lockfile with new dependency tree introduced by datadog-opentelemetry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@jchrostek-dd
Copy link
Contributor

What prompted this? Is this just some code cleanup?

@jchrostek-dd
Copy link
Contributor

jchrostek-dd commented Mar 9, 2026

Add datadog-opentelemetry as a dependency

Any change to the extension size?

- Deduplicate extract_propagation_tags into shared helper in
  traces::propagation
- Use case-insensitive matching for ot-baggage-* header prefix
- Update datadog-opentelemetry to f51cefc
Leftover static fixtures from the old propagation tests were triggering
dead_code warnings with --all-targets.
@duncanista
Copy link
Contributor Author

@jchrostek-dd just cleanup, there's a ticket around there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants